package com.example.easyrpc.register;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 本地注册中心
 */
public class LocalRegister {

    private static final Map<String, Class<?>> registerMap = new ConcurrentHashMap<>();

    /**
     * 注册服务
     *
     * @param interfaceName
     * @param implClass
     */
    public static void register(String interfaceName, Class<?> implClass) {
        registerMap.put(interfaceName, implClass);
    }

    /**
     * 获取服务
     *
     * @param interfaceName
     * @return
     */
    public static Class<?> get(String interfaceName) {
        return registerMap.get(interfaceName);
    }

    /**
     * 删除服务
     *
     * @param interfaceName
     */
    public void remove(String interfaceName) {
        registerMap.remove(interfaceName);
    }
}
